# 根据三个财报数据合成自定义格式数据报表
import os
import pdftool_2 as rtool

# 初始化三个空列表，用于存储负债、利润和现金的范围
fuzai_range = []
lirun_range = []
xianjin_range = []
report_1=[]
report_2=[]
report_3=[]
rep_title=''
xianjin_bcong_range=[]
guben = 0
script_dir = os.path.dirname(os.path.abspath(__file__))# 构建目标文件相对于脚本所在目录的路径

def createRanges():
    # 将报告列表组合成一个二维列表，方便后续处理
    if len(fuzai_range)==0 or len(lirun_range)==0 or len(xianjin_range)==0:
        reports = [report_1, report_2, report_3]
        # 遍历每个报告
        for report in reports:
            # 提取负债、利润和现金的起始页
            fuzai_start, lirun_start, xianjin_start = report
            # 计算负债范围并添加到 fuzai_range 列表中
            fuzai_range.append(range(fuzai_start, lirun_start))
            # 计算利润范围并添加到 lirun_range 列表中
            lirun_range.append(range(lirun_start, xianjin_start))
            # 这里假设每个报告的现金结束页比起始页多 10（因为原需求中未明确给出计算规则，这里只是一种假设）
            xianjin_end = xianjin_start + 5
            xianjin_range.append(range(xianjin_start, xianjin_end))
        # 打印结果
        print("fuzai_range =", fuzai_range)
        print("lirun_range =", lirun_range)
        print("xianjin_range =", xianjin_range)
    
def do_get(save3report=False):
    createRanges()
    # report_fuzai = rtool.read_data_from_csv(f'csv/{rep_title}_负债表.csv')
    # if len(report_fuzai) == 0:
    ranges = fuzai_range
    report_fuzai = rtool.get_fuzai_report(files,ranges)
    if save3report and len(report_fuzai)>0:
        pdf_file_path=os.path.join(script_dir, f'csv/{rep_title}_负债表.csv')
        rtool.save_data_2_number(report_fuzai,pdf_file_path)
        
    # report_lirun = rtool.read_data_from_csv(f'pdf/{rep_title}_利润表.csv')
    # if len(report_lirun) == 0:
    ranges = lirun_range
    report_lirun = rtool.get_lirun_report(files,ranges)
    if save3report and len(report_lirun)>0:
        pdf_file_path=os.path.join(script_dir, f'csv/{rep_title}_利润表.csv')
        rtool.save_data_2_number(report_lirun,pdf_file_path)
            
    # report_xianjin = rtool.read_data_from_csv(f'pdf/{rep_title}_现金表.csv')
    # if len(report_xianjin) == 0:
    ranges = xianjin_range
    report_xianjin = rtool.get_xianjin_report(files,ranges)
    if save3report and len(report_xianjin)>0:
        pdf_file_path=os.path.join(script_dir, f'csv/{rep_title}_现金表.csv')
        rtool.save_data_2_number(report_xianjin,pdf_file_path)
    
    report_xianjin_buchong = []    
    if xianjin_bcong_range is not None and len(xianjin_bcong_range)>0:
        report_xianjin_buchong = rtool.get_xianjin_buchong_report(files,xianjin_bcong_range)
        if save3report and len(report_xianjin_buchong)>0:
            pdf_file_path=os.path.join(script_dir, f'csv/{rep_title}_现金补充表.csv')
            rtool.save_data_2_number(report_xianjin_buchong,pdf_file_path)
        
    if len(report_fuzai)>0 and len(report_lirun)>0 and len(report_xianjin)>0:   
        # 根据年报备注说明手动设定: 应收账款里有多少是银行票据(将银行承兑票据算作是现金，而将商业承兑票据算作是应收账款)
        value_bank_pj=[]
        # 根据年报备注说明手动设定: 其他流动资产里多少属于金融性流动资产(金融性资产除外，则归为经营性流动资产)
        value_qtld_jinrong=[]
        # 一年内到期的非流动资产(内含金融资产，如一年内到期的融资租赁款，可以计为金融资产)
        value_ynndq_fld_jinrong = []
        # 其他非流动资（内含金融资产，如大额存单、委托贷款）
        value_qtfld_jinrong = []
        
        # # 华测检测
        # value_bank_pj = ['17,671,530.15','18,953,226.22','8,930,289.03','17,780,046.55','6,886,588.77','4,985,771.73']
        # value_qtld_jinrong = ['377,393,874.49','452,225,447.82','0.0','0.0','260,357,315.07','330,442,181.44']
        #爱尔眼科
        # # 盈趣科技
        # value_bank_pj=['42,176,268.89','38,332,629.85','13,262,700.39','17,554,445.01','8,681,448.46','0.0']
        # value_qtld_jinrong=['0','100,413,342.47','152,895,342.44','331,502,465.74','']
        # # 五粮液
        # value_bank_pj=['0','0','23,859,058,132.07','18,568,421,154.30','14,643,149,595.72','13,864,930,200.55']
        # guben = 38.82
        # 济川药业
        # value_bank_pj=['46,303,867.35','0','0','0','0','0']
        # guben=9.22
        # 通策
        
        # # 迈瑞
        # value_bank_pj=['1,704,912.00','2,094,202.00','131,697,681.00','96,076,022.00','27,576,422.00','54,460,000.00']
        # guben=12.12
        
        # 长春高新
        # value_bank_pj=['132,816,766.49','242,524,977.180','147,588,857.90','156,907,004.77','136,586,244.56','88,698,832.84']
       
        # 光威复材
        
        # # 潍柴
        # value_bank_pj=['6,141,640,667.29','6,564,601,976.78','9,491,886,182.48','9,604,707,554.86','19,187,372,264.36','15,920,141,988.31']
        # guben=87.27
        # 珀莱雅
        # guben=3.96
        # 隆基绿能
        # value_bank_pj=['296,310,630.64','144,203,326.40','86,492,681.64','12,671,778.46','4,553,400,751.13','3,647,740,296.04']
        # value_qtld_jinrong=['0','0','0','0','100,000,000.00','0']
        # 万华
        # 百川能源
        # value_bank_pj=['7,212,300.00','10,077,397.65','10,668,922.45','3,540,000.00','7,929,207.15','4,743,199.52']
         # 涪陵榨菜
        # value_qtld_jinrong=['922,367,009.63','1,737,509,304.7','2,367,380,480','0','220,000,000.00','320,000,000.00']
        # 紫光国芯
        #乐谱
        # value_bank_pj=['60,631,562.69','68,366,738.81','34,766,157.96','12,351,880.00','33,738,075.21','141,857,631.64']
        # # # 安图生物
        # value_bank_pj=['16,466,455.65','11,580,931.20','0','0','0','0']
        # value_qtld_jinrong=['2,333,497,470.88','3,140,686,333.00','3,000,233,800.00','3,091,870,000.00','611,040,000.00','330,300,000.00']
        # guben=5.71
        # #长江电力
        # value_qtld_jinrong=['156,726,771.14','102,000,948.00','168,904,971.50','852,007,760.00','442,307,961.50','1,012,019,700.00']
        # guben=244.68
        # # # 国投电力
        # value_bank_pj=['44,062,537.46','79,404,417.23','281,867,833.90','457,818,221.86','0','0']
        # guben=80.04
        # # 三峡水利
        # value_bank_pj=['0','0','32,268,850.95','40,838,022.71','39,542,181.78','34,653,200.00']
        # guben=19.12
        # # 川投能源
        # value_bank_pj=['27,720,931.64','46,938,298.42','68,495,773.94','53,549,933.02','22,034,187.17','67,600,000.00']
        # guben=48.75
        # # 牧原股份  
        # value_bank_pj=['152,900,000.00','129,090,000.00','60,000,000.00','0','0','0']
        # value_qtld_jinrong=['0','0','0','0','0','685,000,000.00']
        # guben=54.63
        #中顺洁柔 
        # value_bank_pj=['9,193,142.74','9,871,092.80','2,327,060.20','724,419.74','301,904.32','2,829,930.18']
        # value_qtld_jinrong=['150,000,000','233,001,000','72,479,083.36','50,000,000.00','127,105,000.00','0']
        # 宋城演艺
        # guben=26.23
        # 洽洽食品
        # guben = 5.06
        # 通化东宝
        # value_qtld_jinrong = ['0','0','0','0','202,738,630.14','300,000,000.00']
        # # # 仁和药业
        # value_bank_pj=['45,108,061.94','69,221,423.14','69,536,531.66','0','170,412,258.961','44,891,125.53']
        # value_qtld_jinrong=['0','0','50,000,000.00','700,000,000.00','0','0']
        # 景津装备
        # value_bank_pj=['80,112,385.20','68,258,561.67','21,023,865.12','6,126,441.25','5,116,845.00','0']
        # value_qtld_jinrong=['61,841,581.00','121,103,908.48','0','0','0','0']
        #  迪瑞医疗
        # value_qtld_jinrong = ['21,341,758.24','0','0','0','0','0'] 
        # 京新药业
        # value_qtld_jinrong=['0','0','6,907,879.45','0','90,259,342.47','0']
        # 广信股份
        # value_qtld_jinrong=['0','0','0','0','0','1,770,000,000.00']
        # # 京沪高铁
        # value_qtld_jinrong=['59,856,944.45','24,356,944.45','0','0','0','0'] 
        # guben=491.06
        # 扬农化工
        # value_bank_pj=['652,946,098.38','636,441,496.95','778,826,839.13','534,831,944.53','311,108,226.75','288,656,623.23']
        # value_qtld_jinrong=['1,950,072,825.07','227,754.04','0','0','0','604,000,000.00'] 
        # 晨光股份
        # guben=9.24
        # 杭叉集团
        # guben=13.10
        # 汉钟精机
        # value_qtld_jinrong=['144,361,929.45','41,133,913.54','36,992,656.10','18,888,420.59','0','0']
        # # 三七互娱
        # value_qtld_jinrong=['0','0','360,001,443.35','0','0','0'] 
        # value_qtfld_jinrong=['1,353,003,690.50','1,023,819,464.58','0','0','0','0']
        # 欧普康视  
        # value_qtld_jinrong=['1,111,821,545.46','1,030,441,697.24','222,691,993.83','61,059,799.98','583,400,986.30','312,000,000.00'] 
        # # 华域汽车
        # value_bank_pj=['272,150,385.15','224,642,713.49','733,406,812.60','1,853,929,533.97','2,210,516,865.27','7,015,720,352.76']
        # value_qtld_jinrong=['0','0','290,000,000.00','643,829,592.00','594,212,248.00','571,518,000.00']
        # 山西汾酒
        # value_qtld_jinrong=['17,251,650,967.19','6,017,089,794.52','0','185,539,322.42','374,000,000.00','679,500,000.00']
        # value_qtfld_jinrong=['1,545,493,150.68','1,500,493,150.68','0','0','0','0']
        # 中国汽研
        # value_bank_pj=['685,129,232.68','456,217,840.13','408,255,525.23','364,815,074.08','263,925,050.92','240,870,503.63']
        # # 浙江鼎力
        # value_bank_pj=['20,493,656.30','16,835,605.56','0','0','0','0']
        # guben=5.06
        # 我武生物
        # value_bank_pj=['18,620,344.02','83,207,855.11','82,012,789.82','72,514,745.37','64,726,841.66','53,229,929.05']
        # # 山东药玻
        # value_bank_pj=['676,231,103.74','606,167,382.11','251,523,831.91','187,976,690.05','196,240,269.73','338,583,849.99']
        # value_qtld_jinrong=['0','0','0','0','0','788,000,000.00']
        # guben=6.64
        # 老百姓
        # value_bank_pj=['80,433,190','103,703,906','44,856,149','0','0','0']
        # # 华能水电
        # value_bank_pj=['3,459,369.50','27,112,160.82','18,600,000.00','2,597,295,343.54','2,037,546,147.86','1,358,142,309.76']
        # guben=180.00
        # 华贸物流
        # value_bank_pj=['113,417,071.86','0','0','0','117,289,037.13','126,450,403.88']
        # 华东医药
        # guben=17.54
        # # # 华兰生物
        # guben=18.29
        # value_qtld_jinrong=['700,659,372.88','344,437,959.47','0','0','0','0']
        # value_qtfld_jinrong=['3,246,295,923.81','3,603,095,224.74','1,619,719,931.95','0','0','0']
        # 海天味业
        # guben=55.61
        # # 海康威视
        # value_bank_pj = ['2,199,710,776.69','2,047,876,364.66','1,228,046,849.95','1,003,388,157.28','696,453,713.94','0']
        # guben=92.33
        # 公牛集团
        # value_qtld_jinrong=['50,265,479.45','283,755,939.73','1,114,551,150.68','2,726,587,945.21','2,802,200,000.00','1,045,000,000.00'] 
        # guben=12.92
        # # # 歌尔股份 
        # value_bank_pj=['139,468,321.29','25,847,492.24','48,384,771.72','3,015,027.25','40,186,559.85','18,974,314.37']
        # value_qtfld_jinrong=['998,012,152.77','655,000,458.30','122,540,194.44','0','0','0']
        # 安琪酵母
        # 圣邦股份
        # guben=4.74
        # 中炬高新
        # value_qtld_jinrong=['1,269,012,065.58','844,261,618.23','798,252,426.90','1,285,248,976.39','30,000,000.00','270,000,000.00']
        # guben=7.83
        # 龙佰集团
        # 同仁堂
        # value_bank_pj=['238,833,849.91','464,210,229.92','492,587,968.60','249,350,633.89','513,990,931.95','680,460,922.02']
        
        # # 片仔癀
        # value_bank_pj=['57,395,234.52','73,545,742.21','51,943,609.57','40,391,383.69','10,741,297.36','12,139,402.61']
        # value_qtld_jinrong=['9,014,263,847.05','6,201,992,299.58','0','0','0','0']
        # 泸州老窖
        # guben=14.72
        # 弘亚数控
        # value_qtld_jinrong = ['0','0','0','0','6,000,000.00','0']
        # value_qtfld_jinrong = ['10,514,511.11','0','0','0','0','0']
        # 人福医药
        # 中国巨石
        # value_bank_pj=['958,427,625.05','280,125,689.74','0','0','0','0']
        # 远兴能源
        # value_qtld_jinrong=['0','0','1,761,672,898.72','1,949,670,043.79','2,577,808,094.42','0']
        # 恒瑞医药
        # value_bank_pj=['325,831,647.59','502,790,602.73','1,081,031,081.78','0','528,556,741.86','658,870,046.98']
        # # 贵州茅台
        # value_bank_pj=['1,984,407,967.50','13,933,440.00','105,453,212.00','0','1,532,728,979.67','1,463,000,645.08']
        # guben=12.56
        # # 洋河股份
        # value_bank_pj=['526,476,976.44','526,004,730.00','663,849,328.28','613,496,333.71','659,266,780.81','242,542,097.76']
        # guben = 15.06
        # # 伊利股份
        # value_bank_pj=['214,500,000.00','156,487,000.00','349,050,000.00','0','221,720,000.00','181,100,000.00']
        # value_qtfld_jinrong=['17,630,148,346.08','6,235,858,855.55','0','0','0','0']
        # guben=63.66
        
        # # # 药明2024
        # value_bank_pj=['92,672,778.12','20,196,868.46','74,620,707.44','48,000,000.00','2,500,000.00','24,734,692.87']
        # value_ynndq_fld_jinrong=['734,077,736.67','785,779,534.14','1,427,794,911.22','0','0','0']
        # value_qtfld_jinrong=['0','0','756,315,095.82','2,100,897,541.20','1,320,246,554.82','0']
        # guben=28.88
        # # 双汇发展
        # value_bank_pj=['12,941,960.00','10,200,000.00','49,884,970.84','49,644,623.85','44,600,000.00','58,965,192.00']
        # value_qtld_jinrong=['1,610,826,187.10','3,339,783,799.70','1,845,150,972.09','1,216,223,250.79','246,631,827.20','0']
        # guben=34.65
        # 海尔智家
        # value_bank_pj=['10,320,913,982.40','8,614,523,632.63','9,346,227,149.92','13,053,809,505.49','3,091,631,183.91','462,888,721.91']
        # value_qtld_jinrong=['491,724,709.59','1,530,274,566.66','1,642,421,944.45','316,590,333.42','554,131,037.76','3,981,314,321.50']
        # guben=93.83
        # # 劲仔食品
        # value_qtld_jinrong=['0','70,000,000.00','40,000,000.00','90,000,000.00','40,000,000.00','0']
        # guben=4.51
        # # 东方雨虹
        # guben=23.89
        # value_bank_pj=['355,444,645.62','64,057,470.77','0','0','0','0']
        # # 蓝天燃气
        # guben=7.15
        # value_bank_pj=['1,806,910.00','9,230,000.00','1,796,933.62','0','0','0']
        # 中谷物流
        # guben=21
        #科大讯飞2020
        guben = 23.12
        
        rtool.pro_my_fuzai_report_tofile(report_fuzai,report_lirun,report_xianjin,
                                         report_xianjin_buchong,
                                         value_bank_pj,
                                         value_qtld_jinrong,value_ynndq_fld_jinrong,value_qtfld_jinrong,
                                         os.path.join(script_dir,f'csv/{rep_title}_年报分析.csv'),guben)
        

# rep_title = '华测检测'
# fuzai_range =  [range(109,112),range(117,120),range(88,91)]
# lirun_range = [range(114,115),range(122,124),range(94,95)]
# xianjin_range = [range(117,118),range(127,128),range(99,100)]
# xianjin_bcong_range = [range(244,244),range(281,282),range(224,224)]

# rep_title = '爱尔眼科'
# fuzai_range =  [range(134,136),range(123,126),range(99,102)]
# lirun_range = [range(139,140),range(129,130),range(104,105)]
# xianjin_range = [range(142,143),range(132,133),range(108,109)]
# xianjin_bcong_range = [range(278,278),range(251,251),range(211,211)]

# rep_title = '盈趣科技'
# fuzai_range =  [range(133,137),range(152,156),range(137,141)]
# lirun_range = [range(139,141),range(158,160),range(143,145)]
# xianjin_range = [range(142,145),range(161,163),range(146,149)]
# xianjin_bcong_range = [range(254,254),range(281,281),range(258,258)]

# rep_title = '五粮液'
# fuzai_range =  [range(53,55),range(58,61),range(56,59)]
# lirun_range = [range(57,58),range(63,64),range(62,63)]
# xianjin_range = [range(60,62),range(67,68),range(66,68)]
# xianjin_bcong_range = [range(126,126),range(127,127),range(133,133)]

# rep_title = '济川药业'
# fuzai_range =  [range(106,109),range(93,95),range(76,78)]
# lirun_range = [range(112,113),range(97,98),range(80,81)]
# xianjin_range = [range(116,117),range(101,102),range(84,85)]
# xianjin_bcong_range = [range(209,209),range(180,180),range(157,157)]
# rep_title = '通策'
# fuzai_range =  [range(77,79),range(71,73),range(72,74)]
# lirun_range = [range(81,82),range(75,76),range(76,77)]
# xianjin_range = [range(85,86),range(77,78),range(80,81)]
# xianjin_bcong_range = [range(167,167),range(160,160),range(159,160)]

# rep_title = '迈瑞'
# fuzai_range =  [range(222,227),range(212,215),range(145,148)]
# lirun_range = [range(229,231),range(217,219),range(151,154)]
# xianjin_range = [range(234,235),range(221,223),range(156,158)]
# xianjin_bcong_range = [range(304,305),range(304,304),range(231,231)]

# rep_title = '长春高新'
# fuzai_range =  [range(85,88),range(80,84),range(64,68)]
# lirun_range = [range(91,92),range(87,88),range(71,72)]
# xianjin_range = [range(95,97),range(91,93),range(76,77)]
# xianjin_bcong_range = [range(164,164),range(177,178),range(154,154)]

# rep_title = '光威复材'
# fuzai_range =  [range(88,90),range(100,103),range(77,81)]
# lirun_range = [range(92,94),range(106,108),range(84,87)]
# xianjin_range = [range(94,97),range(110,112),range(89,91)]
# xianjin_bcong_range = [range(175,176),range(199,200),range(180,180)]

# rep_title = '珀莱雅'
# fuzai_range =  [range(93,96),range(77,79),range(70,73)]
# lirun_range = [range(98,100),range(79,83),range(75,77)]
# xianjin_range = [range(101,103),range(84,86),range(78,80)]
# xianjin_bcong_range = [range(193,193),range(161,161),range(156,157)]
# rep_title = '隆基绿能'
# fuzai_range =  [range(121,127),range(105,111),range(96,103)]
# lirun_range = [range(127,131),range(111,115),range(103,108)]
# xianjin_range = [range(131,141),range(115,125),range(108,118)]
# xianjin_bcong_range = [range(253,253),range(228,228),range(230,230)]
# rep_title = '万华'
# fuzai_range =  [range(72,76),range(71,75),range(71,75)]
# lirun_range = [range(76,79),range(75,78),range(75,79)]
# xianjin_range = [range(79,89),range(78,88),range(79,89)]
# xianjin_bcong_range = [range(173,173),range(171,171),range(161,161)]
# rep_title = '百川能源'
# fuzai_range =  [range(77,79),range(69,71),range(77,80)]
# lirun_range = [range(81,82),range(73,74),range(83,84)]
# xianjin_range = [range(85,86),range(77,78),range(87,88)]
# xianjin_bcong_range = [range(182,182),range(170,170),range(171,171)]
# rep_title = '涪陵榨菜'
# fuzai_range =  [range(75,79),range(85,91),range(62,68)]
# lirun_range = [range(79,82),range(91,95),range(68,73)]
# xianjin_range = [range(82,89),range(95,98),range(73,79)]
# xianjin_bcong_range = [range(130,130),range(144,144),range(129,129)]
# rep_title='紫光国芯'
# fuzai_range =  [range(66,67),range(69,70),range(64,68)]
# lirun_range = [range(69,72),range(72,75),range(68,73)]
# xianjin_range = [range(72,79),range(75,78),range(71,79)] 
# ----xianjin_bcong_range = [range(128,128),range(138,138),range(131,131)] #现金补充不是正常表格
# rep_title = '乐谱'
# fuzai_range =  [range(116,121),range(154,159),range(155,161)]
# lirun_range = [range(121,123),range(159,164),range(161,166)]
# xianjin_range = [range(123,128),range(164,174),range(166,176)]
# xianjin_bcong_range = [range(200,200),range(257,258),range(264,264)]

# rep_title = '安图生物'
# fuzai_range =  [range(99,103),range(100,104),range(84,88)]
# lirun_range = [range(103,107),range(104,108),range(88,92)]
# xianjin_range = [range(107,117),range(108,118),range(92,102)]
# xianjin_bcong_range = [range(209,210),range(207,207),range(193,193)]
# rep_title = '长江电力'
# fuzai_range =  [range(88,92),range(75,79),range(57,61)]
# lirun_range = [range(92,95),range(79,83),range(61,65)]
# xianjin_range = [range(95,100),range(83,88),range(65,70)]
# xianjin_bcong_range = [range(206,206),range(177,177),range(153,153)]
# rep_title = '国投电力'
# fuzai_range =  [range(97,101),range(81,85),range(76,80)]
# lirun_range = [range(101,104),range(85,89),range(80,83)]
# xianjin_range = [range(104,108),range(89,98),range(83,90)]
# xianjin_bcong_range = [range(242,242),range(203,203),range(180,181)]
# files = [f'../pdf/{rep_title}2022_ok.pdf', f'../pdf/{rep_title}2020_ok.pdf', f'../pdf/{rep_title}2018_ok.pdf']
# rep_title = '三峡水利'
# fuzai_range =  [range(100,105),range(111,116),range(87,92)]
# lirun_range = [range(105,108),range(116,119),range(92,96)]
# xianjin_range = [range(108,118),range(119,129),range(96,106)]
# xianjin_bcong_range = [range(234,234),range(257,257),range(191,191)]
# rep_title='川投能源'
# report_1 = [108,113,116]
# report_2 = [94,98,102]
# report_3 = [68,73,77]
# xianjin_bcong_range = [range(230,231),range(199,199),range(168,168)]
# rep_title = '中顺洁柔'
# fuzai_range =  [range(92,96),range(101,105),range(105,113)]
# lirun_range = [range(96,100),range(105,111),range(113,119)]
# xianjin_range = [range(100,108),range(111,119),range(119,126)]
# xianjin_bcong_range = [range(183,183),range(189,189),range(222,223)]
# rep_title = '洽洽食品'
# fuzai_range =  [range(93,98),range(100,104),range(72,78)]
# lirun_range = [range(98,101),range(104,108),range(78,83)]
# xianjin_range = [range(101,108),range(108,118),range(83,90)]
# xianjin_bcong_range = [range(213,213),range(204,204),range(174,174)]
# rep_title = '通化东宝'
# fuzai_range =  [range(98,103),range(90,95),range(79,84)]
# lirun_range = [range(103,107),range(95,99),range(84,89)]
# xianjin_range = [range(107,118),range(99,118),range(89,99)]
# xianjin_bcong_range = [range(206,206),range(199,199),range(187,187)]
# rep_title = '仁和药业'
# fuzai_range =  [range(80,85),range(87,93),range(69,75)]
# lirun_range = [range(85,88),range(93,98),range(75,80)]
# xianjin_range = [range(88,98),range(98,108),range(80,90)]
# xianjin_bcong_range = [range(179,179),range(178,178),range(160,160)]
# rep_title = '景津装备'
# fuzai_range =  [range(74,78),range(74,79),range(54,59)]
# lirun_range = [range(78,81),range(79,82),range(59,62)]
# xianjin_range = [range(81,88),range(82,88),range(62,70)]
# xianjin_bcong_range = [range(169,169),range(182,183),range(131,131)]
# rep_title = '迪瑞医疗'
# fuzai_range =  [range(122,126),range(112,118),range(105,111)]
# lirun_range = [range(126,129),range(118,123),range(111,116)]
# xianjin_range = [range(129,138),range(123,128),range(116,126)]
# xianjin_bcong_range = [range(192,192),range(197,197),range(189,189)]

# rep_title = '京新药业'
# fuzai_range =  [range(75,80),range(76,82),range(75,81)]
# lirun_range = [range(80,82),range(82,86),range(81,85)]
# xianjin_range = [range(82,88),range(86,98),range(85,96)]
# xianjin_bcong_range = [range(151,151),range(166,166),range(179,179)]
# 
# rep_title = '广信股份'
# fuzai_range =  [range(76,80),range(85,89),range(70,75)]
# lirun_range = [range(80,84),range(89,92),range(75,79)]
# xianjin_range = [range(84,89),range(92,98),range(79,86)]
# xianjin_bcong_range = [range(203,203),range(202,203),range(183,183)]
# rep_title = '京沪高铁'
# fuzai_range =  [range(59,64),range(60,65),range(63,66)]
# lirun_range = [range(64,67),range(65,68),range(66,68)]
# xianjin_range = [range(67,79),range(68,78),range(68,76)]
# xianjin_bcong_range = [range(137,137),range(141,141),range(121,121)]

# rep_title = '扬农化工'
# fuzai_range =  [range(80,85),range(69,74),range(69,74)]
# lirun_range = [range(85,89),range(74,78),range(74,78)]
# xianjin_range = [range(89,99),range(78,88),range(78,86)]
# xianjin_bcong_range = [range(201,201),range(180,180),range(178,178)]
# rep_title = '晨光股份'
# fuzai_range =  [range(73,77),range(77,89),range(59,63)]
# lirun_range = [range(77,81),range(81,92),range(63,67)]
# xianjin_range = [range(81,89),range(84,98),range(67,76)]
# xianjin_bcong_range = [range(169,169),range(180,180),range(163,163)]
# rep_title = '杭叉集团'
# fuzai_range =  [range(95,99),range(84,88),range(69,73)]
# lirun_range = [range(99,102),range(88,92),range(73,76)]
# xianjin_range = [range(102,109),range(92,98),range(76,86)]
# xianjin_bcong_range = [range(196,196),range(180,180),range(155,155)]
# rep_title = '汉钟精机'
# fuzai_range =  [range(79,83),range(77,82),range(74,78)]
# lirun_range = [range(83,86),range(82,86),range(78,81)]
# xianjin_range = [range(86,99),range(86,98),range(81,86)]
# xianjin_bcong_range = [range(170,170),range(177,177),range(163,163)]
# rep_title = '三七互娱'
# fuzai_range =  [range(78,83),range(90,96),range(84,90)]
# lirun_range = [range(83,85),range(96,99),range(90,94)]
# xianjin_range = [range(85,89),range(99,108),range(94,99)]
# xianjin_bcong_range = [range(153,153),range(180,180),range(181,181)]
# rep_title = '欧普康视'
# files = ['pdf/欧普康视2023_ok.pdf','pdf/欧普康视2021_ok.pdf','pdf/欧普康视2019_ok.pdf']
# fuzai_range =  [range(123,128),range(86,91),range(88,94)]
# lirun_range = [range(128,131),range(91,96),range(94,98)]
# xianjin_range = [range(131,139),range(96,108),range(98,109)]
# xianjin_bcong_range = [range(264,264),range(203,204),range(187,188)]
# rep_title = '华域汽车'
# fuzai_range =  [range(70,74),range(66,70),range(64,68)]
# lirun_range = [range(74,77),range(70,73),range(68,72)]
# xianjin_range = [range(77,89),range(73,78),range(72,79)]
# xianjin_bcong_range = [range(172,172),range(169,169),range(165,165)]
# rep_title = '山西汾酒'
# files = ['pdf/山西汾酒2023_ok.pdf','pdf/山西汾酒2021_ok.pdf','pdf/山西汾酒2019_ok.pdf']
# fuzai_range =  [range(54,58),range(52,56),range(57,68)]
# lirun_range = [range(58,61),range(56,59),range(62,72)]
# xianjin_range = [range(61,69),range(59,68),range(66,79)]
# xianjin_bcong_range = [] #[range(160,160),range(148,148),range(148,148)]
# rep_title = '中国汽研'
# fuzai_range =  [range(89,93),range(80,84),range(65,68)]
# lirun_range = [range(93,97),range(84,87),range(69,72)]
# xianjin_range = [range(97,109),range(87,98),range(73,79)]
# xianjin_bcong_range = [range(216,216),range(189,190),range(169,169)]
# rep_title = '浙江鼎力'
# fuzai_range =  [range(75,79),range(64,68),range(71,74)]
# lirun_range = [range(79,82),range(68,70),range(74,77)]
# xianjin_range = [range(82,89),range(70,78),range(77,89)]
# xianjin_bcong_range = [range(161,162),range(163,163),range(156,156)]
# rep_title = '我武生物'
# fuzai_range =  [range(78,83),range(77,83),range(61,67)]
# lirun_range = [range(83,86),range(83,87),range(67,71)]
# xianjin_range = [range(86,99),range(87,98),range(71,79)]
# xianjin_bcong_range = [range(135,135),range(148,149),range(128,129)]
# rep_title = '山东药玻'
# fuzai_range =  [range(76,80),range(57,61),range(61,66)]
# lirun_range = [range(80,83),range(61,64),range(66,69)]
# xianjin_range = [range(83,89),range(64,68),range(69,79)]
# xianjin_bcong_range = [range(157,157),range(132,132),range(131,131)]
# rep_title = '老百姓'
# fuzai_range =  [range(91,96),range(83,87),range(79,83)]
# lirun_range = [range(96,99),range(87,90),range(83,87)]
# xianjin_range = [range(99,109),range(90,98),range(87,99)]
# xianjin_bcong_range = [range(213,214),range(202,202),range(167,167)]
# rep_title = '华能水电'
# fuzai_range =  [range(97,101),range(88,92),range(71,75)]
# lirun_range = [range(101,104),range(92,96),range(75,79)]
# xianjin_range = [range(104,109),range(96,108),range(79,89)]
# xianjin_bcong_range = [range(220,220),range(195,196),range(171,171)]
# rep_title = '华贸物流'
# report_1 = [82,86,90]
# report_2 = [96,100,103]
# report_3 = [93,97,101]
# xianjin_bcong_range = [range(204,204),range(245,246),range(211,211)]
# rep_title = '华东医药'
# report_1 = [144,148,151]
# report_2 = [118,124,128]
# report_3 = [100,106,111]
# xianjin_bcong_range = [range(258,259),range(212,213),range(191,191)]
# rep_title = '华兰生物'
# report_1 = [66,71,74]
# report_2 = [61,67,71]
# report_3 = [66,72,77]
# xianjin_bcong_range = [range(152,152),range(148,149),range(152,152)]
# rep_title = '海天味业'
# report_1 = [75,79,82]
# report_2 = [73,77,80]
# report_3 = [70,74,77]
# xianjin_bcong_range = [range(168,169),range(162,162),range(151,151)]
# rep_title = '海康威视'
# report_1 = [160,164,166]
# report_2 = [154,158,160]
# report_3 = [124,128,130]
# xianjin_bcong_range = [range(243,243),range(239,239),range(201,201)]
# rep_title = '公牛集团'
# report_1 = [97,102,105]
# report_2 = [86,90,94]
# report_3 = [81,86,91]
# xianjin_bcong_range = [range(182,182),range(170,170),range(170,170)]
# rep_title = '歌尔股份'
# report_1 = [91,95,98]
# report_2 = [93,98,102]
# report_3 = [70,76,80]
# xianjin_bcong_range = [range(196,196),range(207,207),range(176,176)]
# rep_title = '安琪酵母'
# report_1 = [81,86,89]
# report_2 = [81,85,88]
# report_3 = [60,65,69]
# xianjin_bcong_range = [range(177,177),range(171,171),range(147,147)]
# rep_title = '圣邦股份'
# report_1 = [82,86,90]
# report_2 = [86,92,96]
# report_3 = [94,100,103]
# xianjin_bcong_range = [range(162,162),range(170,171),range(175,175)]
# rep_title = '宋城演艺'
# report_1 = [76,80,83]
# report_2 = [66,71,76]
# report_3 = [75,80,84]
# xianjin_bcong_range = [range(156,157),range(148,149),range(148,148)]

# rep_title='中炬高新'
# report_1 = [67,71,75]
# report_2 = [86,91,95]
# report_3 = [53,57,61]
# xianjin_bcong_range = [range(155,155),range(190,190),range(145,145)]
# rep_title='龙佰集团'
# report_1 = [167,172,176]
# report_2 = [145,150,155]
# report_3 = [84,90,95]
# xianjin_bcong_range = [range(285,285),range(277,278),range(213,213)]
# rep_title='同仁堂'
# report_1 = [74,78,81]
# report_2 = [67,71,75]
# report_3 = [56,60,63]
# xianjin_bcong_range = [range(181,182),range(174,174),range(149,149)]
# rep_title='片仔癀'
# report_1 = [103,107,110]
# report_2 = [106,110,113]
# report_3 = [100,105,109]
# xianjin_bcong_range = [range(264,264),range(244,244),range(221,221)]
# rep_title='泸州老窖'
# report_1 = [82,87,90]
# report_2 = [77,82,87]
# report_3 = [64,70,75]
# xianjin_bcong_range = [range(163,163),range(157,157),range(144,144)]
# rep_title='弘亚数控'
# report_1 = [87,91,94]
# report_2 = [110,115,119]
# report_3 = [88,94,99]
# xianjin_bcong_range = [range(176,176),range(218,219),range(190,190)]
# rep_title='人福医药'
# report_1 = [112,117,121]
# report_2 = [122,127,131]
# report_3 = [83,88,92]
# xianjin_bcong_range = [range(216,216),range(229,230),range(189,189)]
# rep_title='中国巨石'
# report_1 = [69,73,76]
# report_2 = [75,79,82]
# report_3 = [62,66,69]
# xianjin_bcong_range = [range(152,153),range(153,154),range(138,138)]
# rep_title='远兴能源'
# report_1 = [87,91,94]
# report_2 = [92,98,101]
# report_3 = [75,81,84]
# xianjin_bcong_range = [range(174,174),range(180,180),range(157,157)]
# rep_title='恒瑞医药'
# report_1 = [145,147,149]
# report_2 = [121,123,125]
# report_3 = [59,61,62]
# xianjin_bcong_range = [range(218,218),range(193,193),range(125,125)]

# rep_title='洋河股份'
# report_1 = [72,77,80]
# report_2 = [80,85,90]
# report_3 = [72,78,82]
# xianjin_bcong_range = [range(150,151),range(169,169),range(154,154)]

# rep_title='伊利股份'
# report_1 = [84,88,91]
# report_2 = [81,85,88]
# report_3 = [72,76,79]
# xianjin_bcong_range = [range(216,216),range(216,216),range(196,196)]

# files = [f'../pdf/{rep_title}2023_ok.pdf', f'../pdf/{rep_title}2021_ok.pdf', f'../pdf/{rep_title}2019_ok.pdf']
# files = [os.path.join(script_dir,f'../pdf/{rep_title}2023_ok.pdf'),os.path.join(script_dir,f'../pdf/{rep_title}2021_ok.pdf'), os.path.join(script_dir,f'../pdf/{rep_title}2019_ok.pdf')]

# -------------2024--------------------

# rep_title='药明'
# report_1 = [133,136,139]
# report_2 = [125,128,131]
# report_3 = [120,124,127]
# xianjin_bcong_range = [range(241,241),range(239,239),range(232,232)]

# rep_title = '潍柴'
# report_1 = [86,91,94]
# report_2 = [85,89,93]
# report_3 = [78,83,87]
# xianjin_bcong_range = [range(170,170),range(176,176),range(172,173)]

# rep_title = '双汇发展'
# report_1 = [110,115,118]
# report_2 = [110,115,120]
# report_3 = [116,122,127]
# xianjin_bcong_range = [range(222,222),range(216,216),range(230,230)]
# rep_title = '海尔智家'
# report_1 = [117,121,124]
# report_2 = [107,111,114]
# report_3 = [107,111,114]
# xianjin_bcong_range = [range(206,206),range(198,198),range(194,194)]
# rep_title='牧原股份'
# report_1 = [129,133,137]
# report_2 = [138,142,146]
# report_3 = [129,134,139]
# xianjin_bcong_range = [range(221,221),range(250,250),range(250,250)]
# rep_title='贵州茅台'
# report_1 = [58,63,66]
# report_2 = [54,58,61]
# report_3 = [49,53,56]
# xianjin_bcong_range = [range(116,116),range(106,107),range(100,101)]
# rep_title='劲仔食品'
# report_1 = [70,75,77]
# report_2 = [70,75,77]
# report_3 = [63,67,70]
# xianjin_bcong_range = [range(135,135),range(126,126),range(116,116)]
# rep_title='东方雨虹'
# report_1 = [188,193,196]
# report_2 = [198,202,205]
# report_3 = [152,157,162]
# xianjin_bcong_range = [range(300,300),range(311,311),range(269,270)]
# rep_title='蓝天燃气'
# report_1 = [69,74,78]
# report_2 = [67,71,75]
# report_3 = [64,69,73]
# xianjin_bcong_range = [range(194,194),range(154,154),range(166,166)]
# rep_title='中谷物流'
# report_1 = [78,82,86]
# report_2 = [77,81,85]
# report_3 = [70,74,77]
# xianjin_bcong_range = [range(173,174),range(153,154),range(145,145)]
rep_title = '科大讯飞'
report_1 = [114,119,122]
report_2 = [104,109,113]
report_3 = [107,112,117]
xianjin_bcong_range = [range(232,232),range(226,226),range(223,224)]

# files = [f'../pdf/{rep_title}2024_ok.pdf', f'../pdf/{rep_title}2022_ok.pdf', f'../pdf/{rep_title}2020_ok.pdf']
files = [os.path.join(script_dir,f'../pdf/{rep_title}2024_ok.pdf'), os.path.join(script_dir,f'../pdf/{rep_title}2022_ok.pdf'), os.path.join(script_dir,f'../pdf/{rep_title}2020_ok.pdf')]

# 非表格财报：格力、重庆啤酒、中国中免、中兴通讯、江西铜业、丽珠集团

do_get()